// 负责管理商品详情中的数据源
import { defineStore } from 'pinia'
import request from '@/utils/request'
import { ApiRes, GoodsInfo } from '@/types/data'
const useGoodsStore = defineStore('goods', {
  state: () => {
    return {
      // 商品详情的数据
      info: {} as GoodsInfo
    }
  },
  actions: {
    // 获取商品详情
    async getInfo (id: string) {
      const res = await request.get<ApiRes<GoodsInfo>>('/goods', {
        params: {
          id
        }
      })
      this.info = res.data.result
    }
  },
  getters: {}
})
export default useGoodsStore
